package top.codedance.iotp.simulator.serialPort.srs.lighting;

import top.codedance.iotp.common.util.BytesBuilder;
import top.codedance.iotp.common.util.HexCodec;
import top.codedance.iotp.simulator.serialPort.srs.Simulator;

import java.util.ArrayList;
import java.util.List;

/**
 * 思域照明
 */
public class Seekway418X implements Simulator {
    @Override
    public List<BytesBuilder> exec(byte[] cmd) {
        List<BytesBuilder> results = new ArrayList<>();
        HexCodec hc = new HexCodec();
        String c = hc.toHex(cmd).replaceAll("\\s+", "").toUpperCase();
        if (c.startsWith("55AA")) {
            String command = c.substring(4, 6);
            //查询模式
            if (command.equals("01")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B1 03 01 01 01".getBytes());
                results.add(bb);
            }
            //更改模式
            if (command.equals("21")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B1 03 01 01 01".getBytes());
                results.add(bb);
            }
            //查询速度
            if (command.equals("02")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B2 01 0A".getBytes());
                results.add(bb);
            }
            //更改速度
            if (command.equals("22")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B2 01 0A".getBytes());
                results.add(bb);
            }
            //查询亮度
            if (command.equals("03")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B3 01 01".getBytes());
                results.add(bb);
            }
            //查询亮度
            if (command.equals("23")) {
                BytesBuilder bb = new BytesBuilder();
                bb.append("55 AA B3 01 01".getBytes());
                results.add(bb);
            }
        }
        return results;
    }
}
